package cn.iocoder.yudao.module.xkfz.controller.admin.excel;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.xkfz.controller.admin.excel.result.CommonExcelResult;
import cn.iocoder.yudao.module.xkfz.domain.excel.entity.AchievementAward;
import cn.iocoder.yudao.module.xkfz.domain.excel.entity.PatentTransfer;
import cn.iocoder.yudao.module.xkfz.domain.excel.entity.Standard;
import cn.iocoder.yudao.module.xkfz.domain.excel.po.PatentTransferPo;
import cn.iocoder.yudao.module.xkfz.domain.excel.po.StandardPo;
import cn.iocoder.yudao.module.xkfz.service.excel.PatentTransferService;
import cn.iocoder.yudao.module.xkfz.service.excel.StandardService;
import cn.iocoder.yudao.module.xkfz.util.ExcelHeaderExtractor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * @Description 专利转化
 * @Author ZWC
 * @Date 2024/5/13 13:38
 */
@RestController
@RequestMapping("patentTransfer")
public class PatentTransferController {

    @Autowired
    private PatentTransferService patentTransferService;

    @PostMapping("importPatentTransfer")
    public CommonResult<Boolean> importPatentTransfer(@RequestParam("file") MultipartFile file,@RequestParam("year")  String year
            ,@RequestParam("indexId")  String indexId) throws IOException {
        List<PatentTransfer> list = ExcelUtils.read(file, PatentTransfer.class);
        return success(patentTransferService.importPatentTransfer(list, year, indexId));
    }

    @GetMapping("selectPage")
    public CommonExcelResult<PageResult<PatentTransfer>> selectPage (PatentTransferPo reqVO){
        List<HashMap<String, String>> headerList = ExcelHeaderExtractor.getHeaderList(PatentTransfer.class);
        return CommonExcelResult.success(patentTransferService.selectPage(reqVO), headerList);
    }
    @PostMapping("insert")
    public CommonResult<Boolean> insert(PatentTransfer patentTransfer){
        return success(patentTransferService.insert(patentTransfer));
    }
    @PostMapping("update")
    public CommonResult<Boolean> update(PatentTransfer patentTransfer){
        return success(patentTransferService.update(patentTransfer));
    }

    @PostMapping("delete")
    public CommonResult<Boolean> delete(String id){
        return success(patentTransferService.delete(id));
    }
}
